<?php

namespace App\BO\OrderStatus\State;

use App\BO\OrderStatus\Events\OrderDistributedEvent;
use App\BO\OrderStatus\FlowTrait\AdminApplyRefundTrait;

class PendingCouldDispatchState extends AOrderState
{
    use AdminApplyRefundTrait;

    protected $desc = '末支付可派单';

    protected $state = '待支付，可派单';

    /**
     * @return bool
     */
    public function couldDistribute()
    {
        return true;
    }

    public function couldAdminApplyRefund()
    {
        return true;
    }

    /**
     * 分配操作
     * @return mixed|void
     * @throws \Exception
     */
    public function distribute()
    {
        $this->toWaitingService();
        event(new OrderDistributedEvent($this->stateContext->getOrder()));  // 订单已经分配过了，待服务
    }
}
